package com.whxd.system.resource.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.apache.commons.lang3.builder.ToStringBuilder;

import com.whxd.system.authority.entity.Authority;

@Entity
@Table(name = "sys_resource")
public class Resource {

	/*--------------------------------------------------
	 * 属性
	 * -----------------------------------------------*/
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(nullable = false)
	private Long id;

	@Column(nullable = false, unique = true)
	private String name;

	private String description;

	private String type;

	private String string;

	private Integer orders;

	private Boolean enabled = true;

	@ManyToMany(mappedBy = "resources")
	private List<Authority> ahthorities = new ArrayList<Authority>();

	/*--------------------------------------------------
	 * Setter/Getter
	 * -----------------------------------------------*/

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getString() {
		return string;
	}

	public void setString(String string) {
		this.string = string;
	}

	public Integer getOrders() {
		return orders;
	}

	public void setOrders(Integer orders) {
		this.orders = orders;
	}

	public List<Authority> getAhthorities() {
		return ahthorities;
	}

	public void setAhthorities(List<Authority> ahthorities) {
		this.ahthorities = ahthorities;
	}

	public Boolean getEnabled() {
		return enabled;
	}

	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

}
